package edu.cuit.avatar;

/**
 * byte      ==      Byte
 * short     ==      Short
 * int       ==      Integer
 * long      ==      Long
 * float     ==      Float
 * double    ==      Double
 * char      ==      Character
 * boolean   ==      Boolean
 */
public class StringDemo {
    public static void main(String[] args) {
        System.out.println("test".toUpperCase());
        System.out.println("Test".toLowerCase());

        System.out.println("  this is a pen!  ".trim()); //去掉字符串前后两端的空格，返回一个新的字符串

        System.out.println("peppa".compareTo("emily")); //大于0
        System.out.println("peppa".compareTo("peppa")); //0
        System.out.println("dannie".compareTo("emily"));//小于0
        System.out.println("peppa".compareToIgnoreCase("Peppa")); //0

        System.out.println("avatar:peppa".startsWith("ava")); //true
        System.out.println("avatar:peppa".startsWith("peppa")); //false
        System.out.println("avatar:peppa".endsWith("peppa")); //true

        //从第3(字符串索引基于0的)字符开始截取到结尾
        System.out.println("welcome to java!".substring(2));
        //从第3(字符串索引基于0的)字符开始截取到第9个(不包含): 8-2
        System.out.println("welcome to java!".substring(2, 8));

        System.out.println("this is a pen".indexOf("is")); //2
        System.out.println("this is a pen".indexOf("apple")); //-1

        System.out.println("this is a pen".lastIndexOf("is")); //5
        System.out.println("this is a pen".lastIndexOf("apple")); //-1

        int number = 100;
        String str = number + "";
        String str1 = String.valueOf(number);
        System.out.println(str == str1); //false
        System.out.println(str.equals(str1)); //true
        System.out.println(str.length());

        String num = "100";
        int number2 = Integer.parseInt(num);
        System.out.println(number2 + 10); //110
        System.out.println(Integer.parseInt("ABCD", 16));
        System.out.println(Integer.parseInt("011010101", 2));
    }
}
